package com.example.booksystem.dao;

import com.example.booksystem.model.BookInfo;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@Repository
public class BookDao {
    public List<BookInfo> mockData() {
        List<BookInfo> books = new ArrayList<>(15);//此处直接将图书数量定为15本
        for (int i = 0; i < 15; i++) {
            BookInfo book = new BookInfo();
            book.setId(i);
            book.setBookName("图书"+i);
            book.setAuthor("作者"+i);
            book.setCount(new Random().nextInt(200));
            book.setPrice(new BigDecimal(new Random().nextInt(100)));
            book.setPublish("出版社"+i);
            book.setStatus(i % 3 == 0 ? 0 : 1);
            books.add(book);
        }
        return books;
    }
}
